jsun.run(function(){
//////////////////////////////////////////////////

function CancelOrder() {
    jsun.ajax.send_request({ asyn: false,
        param: "u=Reader/CancelOrder&order_id="
            + this.getAttribute("data-id") });

    jsun.json.load(function(p) {
        var div = jsun('#OrderListDiv');
        div.innerHTML = "";
        div.appendChild(jsun.dom.from_json(p));
    }, 'u=Reader&m=Reader\\Order/OrderListTable');

    return true;
}

function ClearOrders() {
    jsun.ajax.send_request({ param: "u=Reader/ClearOrders", asyn: false });

    var row = this.parentNode.parentNode.nextSibling;

    while (row) {
        var rows = row.nextSibling;
        row.parentNode.removeChild(row);
        row = rows;
    }
    return true;
}

var list = jsun("#OrderTable").firstChild.childNodes;
jsun.dom.mix(list[0].lastChild.firstChild).event({onclick: ClearOrders});

for (var i = 1; i < list.length; ++i) {
    var item = list[i].lastChild.firstChild;
    jsun.dom.mix(item).event({onclick: CancelOrder});
}

//////////////////////////////////////////////////
});



